//
//  ViewController.m
//  URLSessionTest
//
//  Created by mac on 2017/7/4.
//  Copyright © 2017年 yyb. All rights reserved.
//

#import "ViewController.h"
#import "NetWork.h"
#import "NetWorkManager.h"
#import "DoubanRequest.h"
#import "BaiduRequest.h"
#import "SoplarLoginRequest.h"
#import "LvwenhanRequest.h"
#import "ShakespeareAPI.h"
#import "JSONDictionary.h"
#import "XMLDictionary.h"

@interface ViewController ()
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (IBAction)mainButtonBeTapped:(UIButton *)sender {
//    [self https];
//    [self https1];
    [self https2];
//    [self https3];
//    [self https4];
    [self https5];
}

- (void)https {
    SoplarLoginRequest *api = [[SoplarLoginRequest alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSString *string = [[NSString alloc] initWithData:request.responseData  encoding:NSUTF8StringEncoding];
        NSLog(@"思谱乐同意协议  请求成功 %@",string);
        if (request.error) {
            NSLog(@"思谱乐同意协议错误 %@", request.error.description);
        }else {
            NSLog(@"思谱乐同意协议 证书正确");
        }
    }];
}

- (void)https1 {
    SoplarLoginRequest *api = [[SoplarLoginRequest alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSString *string = [[NSString alloc] initWithData:request.responseData  encoding:NSUTF8StringEncoding];
        NSLog(@"思谱乐登录  请求成功 %@",string);
        if (request.error) {
            NSLog(@"思谱乐登录错误 %@", request.error.description);
        }else {
            NSLog(@"思谱乐登录 证书正确");
        }
    }];
}

- (void)https2 {
    BaiduRequest *api = [[BaiduRequest alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSString *string = [[NSString alloc] initWithData:request.responseData  encoding:NSUTF8StringEncoding];
        NSLog(@"百度  请求成功 %@",string);
        if ([request.responseObject isKindOfClass:[NSXMLParser class]]) {
            NSDictionary *dic = [XMLDictionary dictionaryWithXML:request.responseObject];
            NSLog(@"百度 xml%@",dic);
        }
        if (request.error) {
            NSLog(@"百度错误 %@", request.error.description);
        }else {
            NSLog(@"百度 证书正确");
        }
    }];
    
}
- (void)https3 {
    LvwenhanRequest *api = [[LvwenhanRequest alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSString *string = [[NSString alloc] initWithData:request.responseData  encoding:NSUTF8StringEncoding];
        NSLog(@"岁寒  请求成功 %@",string);
        if (request.error) {
            NSLog(@"岁寒错误 %@", request.error.description);
        }else {
            NSLog(@"岁寒 证书正确");
        }
    }];
}


- (void)https4 {
    DoubanRequest *api = [[DoubanRequest alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSDictionary *dic = [JSONDictionary dictionaryWithJSON:request.responseObject];
        NSLog(@"豆瓣  请求成功 %@", dic);
        if (request.error) {
            NSLog(@"豆瓣错误 %@", request.error.description);
        }else {
            NSLog(@"豆瓣 证书正确");
        }
    }];
}

- (void)https5 {
    ShakespeareAPI *api = [[ShakespeareAPI alloc] init];
    [api startWithCompletionBlock:^(NetWorkRequest *request) {
        NSString *string = [[NSString alloc] initWithData:request.responseData  encoding:NSUTF8StringEncoding];
        NSLog(@"Shakespeare  请求成功 %@",string);
        if ([request.responseObject isKindOfClass:[NSXMLParser class]]) {
            NSDictionary *dic = [XMLDictionary dictionaryWithXML:request.responseObject];
            NSLog(@"Shakespeare xml%@",dic);
        }
        if (request.error) {
            NSLog(@"Shakespeare %@", request.error.description);
        }else {
            NSLog(@"Shakespeare 证书正确");
        }
    }];
}
@end
